//
//  JXMessage.h
//  JiaoX
//
//  Created by yinqy on 15/3/13.
//  Copyright (c) 2015年 北京娇羞科技有限公司. All rights reserved.
//

#import <AVOSCloud/AVOSCloud.h>
#import "UserInfo.h"
#import "FMResultSet.h"

typedef NS_ENUM(NSInteger, RoomType) {
    RoomTypeSingle = 0,
    RoomTypeGroup
};

typedef NS_ENUM(NSInteger, MsgType) {
    MsgTypeText = 0,
    MsgTypeImage = 1,
    MsgTypeAudio = 2,
    MsgTypeLocation = 3
};

typedef NS_ENUM(NSInteger, ReadStatus) {
    ReadStatusUnread = 0,
    ReadStatusHaveRead = 1
};

typedef NS_ENUM(NSInteger, SendStatus){
    StatusSendStart = 0,
    StatusSendSucceed = 1,
    StatusSendReceived = 2,
    StatusSendFailed = 3,
    StatusHaveRead = 4
};


@interface JXMessage : AVMessage
@property(nonatomic)int64_t preTimestamp;
@property (nonatomic, copy) NSString *messageId;//消息id
@property (nonatomic, assign) RoomType roomType;// 聊天类型 ,单聊还是群聊
@property (nonatomic, assign) MsgType msgType; //消息类型
@property (nonatomic, assign) ReadStatus readStatus; //消息是否查看
@property (nonatomic, assign) SendStatus sendStatus; //发送状态
@property (nonatomic, copy,readonly) NSString *conversionId;//这条消息的会话id，由fromId与toId排序再md5生成;

+ (JXMessage *)messageForPeerWithSession:(AVSession *)session
                                toPeerId:(NSString *)toPeerId
                                 payload:(NSString *)payload;

/**
 *  图片信息
 *
 *  @param session
 *  @param objectId 这条消息的objectid 代表图片在本地的文件名
 *  @param imgFile  图片在本地的地址
 *  @param toPeerId 发给谁
 *
 *  @return
 */
+ (JXMessage *)imgMsgWithSession:(AVSession *)session objectId:(NSString *)objectId imgFile:(NSString *)imgFile toPeerId:(NSString *)toPeerId imgW:(CGFloat)imgW imgH:(CGFloat)imgH;

+ (JXMessage *)fromAVMessage:(AVMessage *)message;

+ (JXMessage *)fromFMResultSet:(FMResultSet *)set;
/**
 *  获取实际的聊天内容
 *
 *  @return
 */
-(NSString *)actualContent;

/**
 *  设置实际内容 (用于发送的image)
 */
-(void)setActualContent:(NSString *)actual;

/**
 *  获取图片的宽高 ，仅对MsgTypeImage有效
 *
 *  @return
 */
-(CGFloat)getImgW;
-(CGFloat)getImgH;

@end
